#! /usr/bin/python3
# -*- coding: utf-8 -*-
"""
Created on 2020/1/7 14:29 星期二

@author: jyz
"""
from collections import namedtuple
import os
import logging.config
from .getConfigData import get_save_path


# 各算法Id对应的方法名称
ALGORITHM_ID = {10: 'safety_helmet_detection', 20: 'ref_cloth_detection',
                30: 'cross_line_detection', 40: 'crowded_detection',
                50: 'fall_down_detection', 60: 'offsite_detection',
                70: 'loiter_detection', 80: 'bare_soil_detection',
                90: 'fire_smog_detection'}
# {安全帽：10，反光衣：20，越界：30，人员聚集：40，摔倒行为检测：50，人员离岗：60，人员徘徊：70，裸土覆盖：80，火焰检测：90}
ALGORITHM_PARAMS = {30: ['linePoint'],
                    40: ['polygonPoint', 'personNum'],
                    60: ['personNum', 'times']}
# 算法Id对应的所需参数
DEVICE_ALGORITHM = namedtuple('device_id', 'id algorithm timeList params')
DEVICE_ALG = {'': []}

# 各个模型的路径
models = 'model/'
MODEL_PATH = {10: os.path.join(models, 'safety_helmet_model'), 20: os.path.join(models, 'ref_cloth_model'),
              30: os.path.join(models, 'cross_line_model'), 40: os.path.join(models, 'crowded_model'),
              50: os.path.join(models, 'fall_model'), 60: os.path.join(models, 'offsite_model'),
              70: os.path.join(models, 'loiter_model'), 80: os.path.join(models, 'bare_soil_model'),
              90: os.path.join(models, 'fire_smog_model')}
CROWDED_MODEL = './model/crowded_model'
CROSS_LINE_MODEL = './model/cross_line_model'
FIRE_MODEL = './model/fire_smog_model'

# gpu_memory_limit
# GPU_MEMORY_LIMIT = 0.17

# 计算结果保存路径返回值faceImgPath, RESULT_IMAGE_PATH
# gpu_memory_limit: 每路算法占用的总显存的比率
# GAP_SECOND： 每隔几秒保存一张报警截图
# STREAM_FPS： 输出视频流的fps
# repeti_retio: 去重截图时对比截图的重复比例,画面中静止的对象越多，该比例越小

_, RESULT_IMAGE_PATH, GPU_MEMORY_LIMIT, STREAM_FPS, GAP_SECOND, repeti_retio, original_img_path = get_save_path()
# faceImgPath, resultImgPath, memory_usage, out_stream_fps, capure_img_rate, img_distinct_ratio

# 获取每个设备的pid
DEVICE_PIDS = {}
ALL_PIDS = []

# 配置日志文件
log_file_path = os.path.join(os.getcwd(), 'config', 'log.conf')
# log_file_path = r"E:\Jie\test_out\detect_v2.3\config\log.conf"
logging.config.fileConfig(log_file_path)
logger = logging.getLogger('detect')


# 设备对应算法保存的截图索引
SCREENSHOT_IDX = {}

# 设备对应算法获取帧索引
FRAME_IDX = {}

# repeti_retio:去重截图时对比截图的重复比例,画面中静止的对象越多，该比例越小
# repeti_retio = 7

# 前端页面的图画框尺寸
rect_size = 1000, 550

# 推流的图像size
STREAM_SIZE = (1280, 720)

# 推理的批次
BITCH_SIZE = 4
# STREAM_FPS： 输出视频流的fps
# STREAM_FPS = 10

# GAP_SECOND每隔几秒保存一张报警截图
# GAP_SECOND = 1
# 设备对应算法保存截图时间戳索引
SAVE_TIMESTAP = {}








